<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('comments', function(Blueprint $table)
		{
			$table->increments('id');
            $table->integer('post_id');
            $table->text('content');
            $table->integer('creator_id');
            $table->integer('sequence_number');

            $table->timestamps();
            $table->softDeletes();

            $table->unique(array('post_id', 'sequence_number'));
		});

        Schema::create('comment_extras', function(Blueprint $table){
            $table->increments('id');
            $table->integer('comment_id');
            $table->integer('likes_count');

            $table->timestamps();
            $table->softDeletes();

            $table->unique('comment_id');
        });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::dropIfExists('comments');

        Schema::dropIfExists('comment_extras');
	}

}
